package common;

public class ListNode {
    public int val;
    public ListNode next;

    public ListNode() {
    }

    public ListNode(int val) {
        this.val = val;
    }

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }

    public static void print(ListNode node) {
        while (node != null) {
            System.out.printf("(%d)", node.val);
            node = node.next;
        }
    }
    public static ListNode read(Integer[]nums) {
        ListNode head = new ListNode();
        ListNode solider = head;
        for (Integer num : nums) {
            head.next = new ListNode(num,null);
            head = head.next;
        }
        return solider.next;
    }
}